package org.openkanban.shared.dto;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.openkanban.client.ui.presenter.RequestParameterMap;
import org.openkanban.client.util.JsonConverter;

/**
 * Data Transfer Object used for transferring Activity information
 */
public class ActivityDto extends StatusDto implements RequestParameterMap {

    private Long activityId;
    private String activityName;
    private int wipLimit;
    private Set<KanbanDto> kanbans;

    public ActivityDto() {
    }

    public ActivityDto(String json) {
	activityId = JsonConverter.getLongValueOrNull(json, "activityId");
	activityName = JsonConverter.getStringValueOrNull(json, "activityName");
	wipLimit = JsonConverter.getIntegerValueOrNull(json, "wipLimit");
	kanbans = JsonConverter.getObjectsAsSet(json, "kanbans", KanbanDto.class);
    }

    public Long getActivityId() {
	return activityId;
    }

    public void setActivityId(Long activityId) {
	this.activityId = activityId;
    }

    public String getActivityName() {
	return activityName;
    }

    public void setActivityName(String activityName) {
	this.activityName = activityName;
    }

    public int getWipLimit() {
	return wipLimit;
    }

    public void setWipLimit(int wipLimit) {
	this.wipLimit = wipLimit;
    }

    public Set<KanbanDto> getKanbans() {
	return kanbans;
    }

    public void setKanbans(Set<KanbanDto> kanbans) {
	this.kanbans = kanbans;
    }

    @Override
    public Map<String, String> valuesToMap() {
	Map<String, String> activityMap = new HashMap<String, String>();
	if (activityId != null) {
	    activityMap.put("activityId", Long.toString(activityId));
	}
	activityMap.put("activityName", activityName);
	activityMap.put("wipLimit", Integer.toString(wipLimit));
	return activityMap;
    }

    @Override
    public String toString() {
	return "ActivityDto [activityId=" + activityId + ", activityName=" + activityName + ", wipLimit=" + wipLimit + "]";
    }

}
